<?php
require_once("htmlHelper.php");

//lets try a simple div with a header and a paragraph
$div = new div(null,"divOne");
$div->h3("This is div One");
$div->p("This is div Ones content");
echo $div->html();

//that was easy, lets try something more
$holder = new holder(); // a holder will not itself return a tag but it will keep a stack of objects
$form =& $holder->form("testForm",$_SERVER['PHP_SELF']); //notice the use of =& to get a reference to the form

$table =& $form->table();
//you can set any attribute you like just by calling the property, be carefull though, the class will
//accept anything
$table->cellpadding = 2;
$table->width = "100%";
$table->cellspacing = 1;
$table->style = "background:#333";


$tdOptions = array("style" => "background:#fff");
$tr =& $table->tr();
//you can pass attributes directly in parameters
$tr->th("Header 1",null,null,$tdOptions);
//or you can call a method when creating, this will not work if you call the same heading again
//a new th will be created
$tr->th("Header 2")->style = "background:#efefef";
//getting a reference to the object is always good if you need to make many changes
$th =& $tr->th("Header 3");
$th->style = "background:#fff;font-size:14px;font-weight:bold";
$th->colspan = 2;

//then lets add another row
$tr =& $table->tr();
$tr->td("Value 1",null,null,$tdOptions);
$tr->td("Value 2",null,null,$tdOptions);
$tr->td("Value 3, in span",null,null,$tdOptions);
$tr->td("Value 4, in span",null,null,$tdOptions);

echo $holder->html();


//i've only just started adding other stuff, see the class itself for reference, it's early days but
//i hope this helps people
$opts = array("Apple","Pear","Grape","Plum","Orange");

$div = new div();
$select = $div->select("testSel");
$select->onchange = "alert(this.value)";
$select->optionsFromArray($opts,3); // currently only selects based on key
echo $div->html();


?>